//
//  SentenceConfig.swift
//  Game
//
//  Created by woniu on 2025/9/2.
//

import Foundation
import HandyJSON

/// 题目配置模型
class SentenceConfig:NSObject,HandyJSON {
    required override init(){}
    /// 完整英语句子
    var sentence = ""
    /// 英语句子中被挖空的单词（原词）
    var blankWord = ""
    /// 答案选项（最多4个）
    var options: [String] = []
    /// 正确答案
    var correctAnswer = ""
    //图片名称
    var imageName = ""

    func jsonString() -> String? {
        let json = self.toJSONString()
        return json
    }
    /// 获取被挖空后的英语句子
    public func  getRenderedSentence()->String {
        if sentence.isEmpty || blankWord.isEmpty {return sentence}
        return sentence.replacingOccurrences(of: "\\b" + NSRegularExpression.escapedPattern(for: blankWord) + "\\b",
                                             with: "_____",
                                             options: .regularExpression)
    }
}



